package unimelb.filesync.common.message;

import org.json.simple.JSONObject;

public class ResponseBlockSizeRole implements Jsonable {
    private final boolean success;

    private final String errorMessage;

    public ResponseBlockSizeRole() {
        this.success = true;
        this.errorMessage = null;
    }

    public ResponseBlockSizeRole(String errorMessage) {
        this.success = false;
        this.errorMessage = errorMessage;
    }

    public boolean isSuccess() {
        return success;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    @SuppressWarnings("unchecked")
    @Override
    public String toJson() {
        final JSONObject jsonObject = new JSONObject();
        jsonObject.put("success", success);
        jsonObject.put("errorMessage", errorMessage);
        return jsonObject.toJSONString();
    }
}
